package com.hnxxxy.jfmgr.mapper;

import com.hnxxxy.common.redis.RedisMyabtisCstCache;
import com.hnxxxy.jfmgr.pojo.Jf_attachment;
import com.hnxxxy.jfmgr.pojo.Jf_conf;
import com.hnxxxy.jfmgr.pojo.Jf_detail;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author：张浩东
 * @Phone：15096207164
 * @QQ：1367048164
 * @E-mail：1367048164@qq.com
 * @date:2020-05-19 16:33
 */

@Mapper
@CacheNamespace(implementation = RedisMyabtisCstCache.class)
public interface JfUserTestimonialsStatusMapper {

    @Select({"<script>",
            "SELECT jd.*,ja.image FROM jf_detail as jd,jf_attachment as ja",
            "<where> ",
            "<if test='userId!=null'>",
            "and jd.user_id = #{userId} and jd.id = ja.jf_detail_id",
            "</if>",
            "<if test='status!=null and status!=0'>",
            "and jd.status = #{status}",
            "</if>",
            "<if test='certificateName!=null'>",
            "and jd.certificate_name  like concat('%',#{certificateName},'%') ",
            "</if>",
            "<if test='updateTime!=null || endTime!=null'>" +
            "<if test='updateTime!=null'>",
            "and jd.update_time &gt;= #{updateTime}",
            "</if>",
            "<if test='endTime!=null'>",
            "and jd.update_time &lt;= #{endTime}",
            "</if>",
            "ORDER BY jd.update_time",
            "</if>",
            "</where>",
            "</script>"})
    List<Jf_detail> findAlUserTestimonialsStatus(Jf_detail jf_detail);

    @Delete("delete from jf_detail where id = #{id}")
    int deleteUserTestimonialsStatus(Integer id);

    @Delete("delete from jf_attachment where jf_detail_id = #{id}")
    int deleteUserTestimonialsAttachment(Integer id);

}
